'use strict';
module.exports = {
	/**
	 * 查询订单
	 * @url admin/order/sys/getList 前端调用的url参数地址
	 * data 请求参数 说明
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		let { data = {}, userInfo, util, filterResponse, originalParam } = event;
		let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
		let { uid } = data;
		let res = { code: 0, msg: "" };
		// 业务逻辑开始-----------------------------------------------------------
		let { status } = data.formData;
		
		let whereJson = {};
		
		if(!vk.pubfn.isNull(status)) {
			whereJson["status"] = status;
		}
		
		let dbName = "db-order";
		
		res = await vk.baseDao.getTableData({
			dbName,
			data,
			whereJson,
			fieldJson: {
				uid: false
			},
			foreignDB: [
				{
					dbName: "uni-id-users",
					localKey:"uid",
					foreignKey:"_id",
					as:"userInfo",
					limit:1,
					fieldJson: {
						nickname: true,
						avatar: true
					}
				}
			],
			sortArr: [{name: "status", type: "asc"}, {name: "_add_time", type: "desc"}]
		});
		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}
